from __future__ import print_function

import copy
import math
import os
import sys
from collections import defaultdict
from operator import gt
from select import select
from time import sleep

import matplotlib.pyplot as plt
import numpy as np

# import matplotlib; matplotlib.use('Agg')

def readFile(path):
    file = open(path, "r")
    tra_list = file.readlines()
    test_file_5 = []
    for i in range(len(tra_list)):
        test_file_5.append(np.array(tra_list[i].strip().split(' '), dtype = np.float64 ))
    test_file_5 = np.array(test_file_5)
    file.close()
    return test_file_5

test_file_1 = readFile("/home/st/ubuntu_data/dataset/gazebo/dynamic_slam/cost_time/gazebo_cost_time.txt")
# test_file_1 = readFile("/home/st/ubuntu_data/dataset/gazebo/dynamic_slam/cost_time/real_cost_time.txt")

plt.scatter(range(test_file_1.shape[0]), test_file_1[:,0])
plt.xlabel('frame')
plt.ylabel('cost time(ms)')
# plt.xlim(-0.2,5)
# plt.ylim(-2.,2.)
print(np.mean(test_file_1))
# plt.plot(x_data,y_data,"r")
plt.show()



